home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / batutl2.zip / SEND.ASM < prev    next >
Assembly Source File  |  1988-04-20  |  8KB  |  357 lines

  1. TITLE    SEND    1-2-86    [4-16-88]
  2. ;Toad Hall Disassembly, tweak
  3.  
  4. LF    EQU    0AH
  5. CR    EQU    0DH
  6. ;
  7. ;INITIAL VALUES :    CS:IP    0000:0100
  8. ;            SS:SP    0000:FFFF
  9.  
  10. CodeSeg    SEGMENT
  11.     ASSUME DS:CodeSeg,SS:CodeSeg,CS:CodeSeg,ES:CodeSeg
  12.     ORG    100H
  13.  
  14. SEND    proc    near
  15.     JMP    SHORT    Start
  16.  
  17. wkday_array    DB    'Sun',0,'Mon',0,'Tue',0,'Wed',0,'Thu',0,'Fri',0,'Sat',0
  18.  
  19. wconst_0A    dw    0AH    ;a constant
  20. wconst_64    dw    64H    ;a constant
  21.  
  22. Start:    MOV    DI,81H            ;PSP cmd line
  23.     MOV    BL,[DI-1]        ;snarf cmd line length byte
  24.     xor    bh,bh            ;clear msb
  25.     mov    byte ptr [bx+di],0    ;stuff AsciiZ 0 in cmd line
  26.  
  27. Lup130:    CALL    Get_CmdLine_Char
  28.     JZ    Exit_140        ;0 means done
  29.     CMP    AL,' '            ;space?
  30.     JZ    Lup130            ; yep, gobble spaces
  31.     CMP    AL,9            ;tab?
  32.     JZ    Lup130            ; yep, gobble them too
  33.     JMP    SHORT    Process_Char_147    ;something else, go process it
  34.  
  35. Exit_140:
  36.     INT    20H            ;back to DOS, wherever
  37. Send    endp
  38.  
  39.  
  40. Lup142    proc    near
  41.     CALL    Get_CmdLine_Char    ;get next cmd line char
  42.     JZ    Exit_140        ;0 means done
  43.  
  44. Process_Char_147:
  45.     CMP    AL,'^'            ;ctrl char?
  46.     JNZ    Not_Ctrl        ; nope
  47.     CALL    Get_CmdLine_Char    ; yep, get Ctrl char
  48.     JNZ    Make_Ctrl        ;wasn't 0, go process it
  49.      MOV    AL,'^'            ; hmmm, display actual caret
  50. Endit_152:
  51.      CALL    CharOut            ;display the char
  52.      INT    20H            ;terminate
  53.  
  54. Make_Ctrl:
  55.     AND    AL,1FH            ;de-Asciify it
  56. Disp159:CALL    CharOut
  57.     JMP    SHORT    Lup142
  58.  
  59. Not_Ctrl:
  60.     CMP    AL,'$'            ;dollar sign?
  61.     JNZ    Disp159            ;nope, display it, reloop
  62.     CALL    L0167            ;process rest of cmd line
  63.     JMP    SHORT    Lup142
  64. Lup142    endp
  65.  
  66.  
  67. L0167    proc    near
  68.     CALL    Get_CmdLine_Char    ;get next cmd line char
  69.     JNZ    L0170            ; got one
  70.      MOV    AL,'$'
  71.      JMP    SHORT    Endit_152    ;display, terminate
  72.  
  73. L0170:    CMP    AL,'t'            ;wants time?
  74.     JNZ    L019C            ; nope
  75.      MOV    AH,2CH            ;get DOS system time
  76.      INT    21H
  77.      MOV    AL,CH            ;display hours
  78.      CALL    Show_space_byte        ;space-padded
  79.      MOV    AL,':'            ;display colon after hours
  80.      CALL    CharOut
  81.      MOV    AL,CL            ;display minutes
  82.      CALL    Show_zero_byte        ;0-padded
  83.      MOV    AL,':'            ;display colon after minutes
  84.      CALL    CharOut
  85.      MOV    AL,DH            ;display seconds
  86.      CALL    Show_zero_byte        ;0-padded
  87.      MOV    AL,'.'            ;display decimal after seconds
  88.      CALL    CharOut
  89.      MOV    AL,DL            ;display deciseconds
  90.      CALL    Show_zero_byte        ;0-padded
  91.      RET
  92.  
  93. L019C:    CMP    AL,'d'            ;wants weekday name?
  94.     JNZ    L01D1            ; nope
  95.     MOV    AH,2AH            ;get DOS system date
  96.     INT    21H            ;day of week returned in AL
  97.     xor    ah,ah            ;clear msb
  98.     MOV    SI,OFFSET wkday_array    ;weekday array base
  99.     ADD    AX,AX            ;*2
  100.     ADD    AX,AX            ;*4
  101.     ADD    SI,AX            ;add to offset
  102.     CALL    StrOut_2E1        ;display AsciiZ string
  103.     MOV    AL,' '            ;display space
  104.     CALL    CharOut
  105.     MOV    AL,DH            ;display month
  106.     CALL    Show_space_byte        ;space-padded
  107.     MOV    AL,'-'            ;display dash
  108.     CALL    CharOut
  109.     MOV    AL,DL            ;display day
  110.     CALL    Show_zero_byte        ;0-padded
  111.     MOV    AL,'-'            ;display dash
  112.     CALL    CharOut
  113.     MOV    AX,CX            ;show year as integer
  114.     CALL    Show_word
  115.     RET
  116.  
  117. L01D1:    CMP    AL,'p'            ;wants directory name?
  118.     JNZ    L01D9            ; nope
  119.      CALL    Show_DirName_2A3    ;show directory name
  120.      RET
  121.  
  122. L01D9:    CMP    AL,'P'            ;want directory name?
  123.     JNZ    L01EA            ; nope
  124.      CALL    Show_DirName_2A3    ;show directory name
  125.      or    al,al            ;?
  126.      JZ    L01E9            ; just return
  127.       MOV    AL,'\'            ;backslash after subdir name
  128.       CALL    CharOut
  129. L01E9:     RET
  130.  
  131. L01EA:    CMP    AL,'v'            ;wants version nr?
  132.     JNZ    L0206            ; nope
  133.     MOV    AH,30H            ;Get DOS version nr
  134.     INT    21H
  135.     PUSH    AX            ;save version
  136.     xor    ah,ah            ;clear msb, lsb is major version
  137.     CALL    Show_word
  138.     MOV    AL,'.'            ;display period
  139.     CALL    CharOut
  140.     POP    AX            ;restore version
  141.     MOV    AL,AH            ;lsb is minor version
  142.     xor    ah,ah            ;clear msb
  143.     CALL    Show_word        ;show as integer
  144.     RET
  145.  
  146. L0206:    CMP    AL,'n'            ;wants current drive?
  147.     JNZ    L020E            ; nope
  148.      CALL    Show_Drive        ;show current drive
  149.      RET
  150.  
  151. L020E:    CMP    AL,'g'            ;wants greater than?
  152.     JNZ    L0218            ; nope
  153.      MOV    AL,'>'            ;display > char
  154.      CALL    CharOut
  155.      RET
  156.  
  157. L0218:    CMP    AL,'l'            ;wants less than?
  158.     JNZ    L0222            ; nope
  159.      MOV    AL,'<'            ;display < char
  160.      CALL    CharOut
  161.      RET
  162.  
  163. L0222:    CMP    AL,'b'            ;wants vertical bar?
  164.     JNZ    L022C            ; nope
  165.      MOV    AL,7CH            ;display '|' char
  166.      CALL    CharOut
  167.      RET
  168.  
  169. L022C:    CMP    AL,'q'            ;?
  170.     JNZ    L0236            ; nope
  171.      MOV    AL,'='            ;display equal sign
  172.      CALL    CharOut
  173.      RET
  174.  
  175. L0236:    CMP    AL,'h'            ;wants backspace?
  176.     JNZ    L0240            ; nope
  177.      MOV    AL,8            ;display backspace char
  178.      CALL    CharOut
  179.      RET
  180.  
  181. L0240:    CMP    AL,'e'            ;wants Escape char?
  182.     JNZ    L024A            ; nope
  183.      MOV    AL,1BH            ;display Esc char
  184.      CALL    CharOut
  185.      RET
  186.  
  187. L024A:    CMP    AL,'_'            ;wants new line?
  188.     JNZ    L0259            ; nope
  189.      MOV    AL,CR            ;display Cr
  190.      CALL    CharOut
  191.      MOV    AL,LF            ; .. and LF
  192.      CALL    CharOut
  193.      RET
  194.  
  195. L0259:    CMP    AL,'M'            ;wants Month?
  196.     JNZ    L0267            ; nope
  197.      MOV    AH,2AH            ;get date
  198.      INT    21H
  199.      MOV    AL,DH            ;month into AL
  200.      CALL    Show_zero_byte
  201.      RET
  202.  
  203. L0267:    CMP    AL,'D'            ;wants Day?
  204.     JNZ    L0275            ; nope
  205.      MOV    AH,2AH            ;get date
  206.      INT    21H
  207.      MOV    AL,DL            ;day into AL
  208.      CALL    Show_zero_byte
  209.      RET
  210.  
  211. L0275:    CMP    AL,'Y'            ;wants Year?
  212.     JNZ    L028C            ; nope
  213.      MOV    AH,2AH            ;get date
  214.      INT    21H
  215.      MOV    AX,CX            ;year into AX
  216.      xor    dx,dx            ;clear remainder
  217.      DIV    WORD PTR wconst_64    ;constant / 64H
  218.      MOV    AX,DX            ;show remainder
  219.      CALL    Show_zero_byte        ;0-padded
  220.      RET
  221.  
  222. L028C:    CMP    AL,'T'
  223.     JNZ    L029F
  224.      MOV    AH,2CH            ;get time
  225.      INT    21H
  226.      MOV    AL,CH            ;display hours
  227.      CALL    Show_zero_byte        ;0-padded
  228.      MOV    AL,CL            ;display minutes
  229.      CALL    Show_zero_byte        ;0-padded
  230.      RET
  231.  
  232. L029F:    CALL    CharOut            ;just show the char
  233.     RET
  234. L0167    endp
  235.  
  236.  
  237. Show_DirName_2A3    proc    near
  238.     CALL    Show_Drive        ;display current drive char
  239.     MOV    AL,':'            ;display colon
  240.     CALL    CharOut
  241.     MOV    AL,'\'            ;and subdir backslash
  242.     CALL    CharOut
  243.     MOV    AH,47H            ;get current directory
  244.     xor    dl,dl            ;drive ID (current drive)
  245. ;use our stack to provide room for the directory name
  246. ;    SUB    SP,41H            ;back down the stack a bit
  247.     MOV    SI,SP            ;pointer to AsciiZ string
  248.     sub    si,41H            ;back down the stack a little
  249.     INT    21H
  250.     CALL    StrOut_2E1        ;display directory name
  251.     MOV    AL,[SI]            ;snarf first char again
  252. ;    ADD    SP,41H            ;correct SP
  253.     RET
  254. Show_DirName_2A3    endp
  255.  
  256.  
  257. Show_Drive    proc    near
  258.     MOV    AH,19H            ;report current drive
  259.     INT    21H
  260.     ADD    AL,41H            ;asciify
  261.     CALL    CharOut            ;display drive char
  262.     RET
  263. Show_Drive    endp
  264.  
  265.  
  266. Get_CmdLine_Char    proc    near
  267.     MOV    AL,[DI]            ;snarf cmd line char
  268. ;    OR    AL,AL            ;terminating zero? (set ZFlag)
  269. ;    JZ    L02D5            ; yep
  270.      INC    DI            ; bump cmd line ptr
  271.     or    al,al            ;set Zflag in case of terminating 0
  272. L02D5:    RET
  273. Get_CmdLine_Char    endp
  274.  
  275.  
  276. CharOut    proc    near
  277.     PUSH    AX
  278.     PUSH    DX
  279.     MOV    DL,AL        ;need char in DL
  280.     MOV    AH,2        ;display output
  281.     INT    21H
  282.     POP    DX
  283.     POP    AX
  284.     RET
  285. CharOut    endp
  286.  
  287.  
  288. StrOut_2E1    proc    near
  289.     PUSH    SI            ;preserve text pointer
  290. Lup2E2:    MOV    AL,[SI]            ;snarf text byte
  291.     or    al,al            ;zero means done
  292.     JZ    L02EE            ;done
  293.      CALL    CharOut            ;display char
  294.      INC    SI            ;bump text ptr
  295.      JMP    SHORT    Lup2E2
  296.  
  297. L02EE:    POP    SI            ;restore text pointer
  298.     RET
  299. StrOut_2E1    endp
  300.  
  301.  
  302. Show_word    proc    near
  303.     or    ax,ax            ;value = 0?
  304.     JNZ    Check_10        ; nope
  305.      CALL    Show_Digit        ;just show a '0'
  306.      RET
  307.  
  308. Check_10:
  309.     CMP    AX,wconst_0A        ;< 10?
  310.     JNB    L0307            ; nope
  311. Show_Digit:
  312.      PUSH    AX            ;save value
  313.      ADD    AL,30H            ;asciify decimal digit
  314.      CALL    CharOut            ;display
  315.      POP    AX            ;restore value
  316.      RET
  317.  
  318. L0307:    PUSH    DX            ;save dx
  319.     xor    dx,dx            ;clear remainder
  320.     DIV    WORD PTR wconst_0A
  321.     PUSH    DX            ;save remainder
  322.     CALL    Check_10        ;show 10's digit if any
  323.     POP    AX            ;restore remainder
  324.     CALL    Show_Digit        ;show 1's digit
  325.     POP    DX
  326.     RET
  327. Show_word    endp
  328.  
  329.  
  330. ;Display byte in AL, with leading 0 if < 10
  331. Show_zero_byte    proc    near
  332.     MOV    BL,'0'            ;lead with '0' if < 10
  333.     JMP    SHORT    L0320        ;skip
  334. Show_zero_byte    endp
  335.  
  336.  
  337. ;display byte with leading space if < 10
  338. Show_space_byte    proc    near
  339.     MOV    BL,' '            ;lead with space if < 10
  340. L0320:
  341.     xor    ah,ah            ;clear msb
  342.     DIV    BYTE PTR wconst_0A    ;/ 10
  343.     CMP    AL,0            ;remainder?
  344.     JG    L0332            ; yep
  345.     MOV    AL,BL            ;display '0' or ' '
  346.     CALL    CharOut
  347.     JMP    SHORT    L0335        ;display 1's, return
  348.  
  349. L0332:    CALL    Show_Digit        ;show 10's digit
  350. L0335:    MOV    AL,AH            ;show 1's digit
  351.     CALL    Show_Digit
  352.     RET
  353. Show_space_byte    endp
  354.  
  355. CodeSeg    ENDS
  356.     END    SEND
  357.